package cn.home.contract.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.home.common.annotation.Log;
import cn.home.common.core.controller.BaseController;
import cn.home.common.core.domain.AjaxResult;
import cn.home.common.enums.BusinessType;
import cn.home.contract.domain.HomeContractUntreated;
import cn.home.contract.service.IHomeContractUntreatedService;
import cn.home.common.utils.poi.ExcelUtil;
import cn.home.common.core.page.TableDataInfo;

/**
 * 待处理签约Controller
 * 
 * @author homedoctor
 * @date 2025-04-09
 */
@RestController
@RequestMapping("/contractuntreated/untreated")
public class HomeContractUntreatedController extends BaseController
{
    @Autowired
    private IHomeContractUntreatedService homeContractUntreatedService;

    /**
     * 查询待处理签约列表
     */
    @PreAuthorize("@ss.hasPermi('contractuntreated:untreated:list')")
    @GetMapping("/list")
    public TableDataInfo list()
    {
        startPage();
        List<HomeContractUntreated> list = homeContractUntreatedService.getHomeContractUntreated();
        return getDataTable(list);
    }

    /**
     * 导出待处理签约列表
     */
    @PreAuthorize("@ss.hasPermi('contractuntreated:untreated:export')")
    @Log(title = "待处理签约", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HomeContractUntreated homeContractUntreated)
    {
        List<HomeContractUntreated> list = homeContractUntreatedService.selectHomeContractUntreatedList(homeContractUntreated);
        ExcelUtil<HomeContractUntreated> util = new ExcelUtil<HomeContractUntreated>(HomeContractUntreated.class);
        util.exportExcel(response, list, "待处理签约数据");
    }

    /**
     * 获取待处理签约详细信息
     */
    @PreAuthorize("@ss.hasPermi('contractuntreated:untreated:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(homeContractUntreatedService.selectHomeContractUntreatedById(id));
    }

    /**
     * 新增待处理签约
     */
    @PreAuthorize("@ss.hasPermi('contractuntreated:untreated:add')")
    @Log(title = "待处理签约", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HomeContractUntreated homeContractUntreated)
    {
        return toAjax(homeContractUntreatedService.insertHomeContractUntreated(homeContractUntreated));
    }

    /**
     * 修改待处理签约
     */
    @PreAuthorize("@ss.hasPermi('contractuntreated:untreated:edit')")
    @Log(title = "待处理签约", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HomeContractUntreated homeContractUntreated)
    {
        return toAjax(homeContractUntreatedService.updateHomeContractUntreated(homeContractUntreated));
    }

    /**
     * 删除待处理签约
     */
    @PreAuthorize("@ss.hasPermi('contractuntreated:untreated:remove')")
    @Log(title = "待处理签约", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(homeContractUntreatedService.deleteHomeContractUntreatedByIds(ids));
    }
}
